package com.ycy.analyzer.ik;

import org.junit.Test;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;

/**
 * @Author: ycy
 * @CreateDate: 2020/7/6 10:40
 */
public class IK {

  @Test
  public void test() {
//    Reader reader = new StringReader("殷才永在未来一定能有好的发展");

    Reader reader = new StringReader("得饶人处且饶人  安徽省合肥市蜀山区");
    //useSmart true 采用智能分词 false 正向迭代最小细粒度分词
    IKSegmenter ik = new IKSegmenter(reader, true);

    try {
      Lexeme next = null;
      while ((next = ik.next()) != null) {
        System.out.println(next);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  /**
   * 加入 殷才永 和 停顿词 "的" 再看看效果
   */
  @Test
  public void test2() {
    Reader reader = new StringReader("殷才永在未来一定能有一个好的发?展,aaaaa腾∴");
    //useSmart true 采用智能分词 false 正向迭代最小细粒度分词
    IKSegmenter ik = new IKSegmenter(reader, false);

    try {
      Lexeme next = null;
      while ((next = ik.next()) != null) {
        System.out.println(next);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }


}
